// pages/my/my.js
import {ajaxFun} from "../../utils/ajax"
Page({


  data: {
     blo:false,
     userinfo:{}
  },
  onShow(){
    let token=wx.getStorageSync('token');
    if(token){
       this.setData({
         blo:true
       })
    }else{
      this.setData({
        blo:false
      })
    }
  },
  async logoutFun(){
    let result=await ajaxFun("/user/logout","post");
    console.log(result);
    if(result.resultCode===200){
      wx.clearStorage()//清除token
      this.setData({
        userinfo:{}
      })
    }
  },
  onLoad(){
     this.getUserINfo()
  },
 async getUserINfo(){//获取个人信息
   let result=await ajaxFun("/user/info","get");
   if(result.resultCode==200){
      wx.setStorageSync('userInfo',result.data)
     this.setData({
       userinfo:{...result.data,userImg:'/images/amy.png'}
     })
   }
 }
 
})